<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class DriverRequest extends FormRequest
{
    protected array $scenes = [
        'add' => ['company_id',  'username', 'sex', 'adm_division_code','birthday','id_card','id_car_front_img','id_car_back_img','id_car_hand_img','head_img','mailing_address','driver_license','driver_license_type','license_first_date','license_start_date', 'license_end_date','license_front_img','license_back_img','sign_company','sign_start_date','sign_end_date','status'],
        'edit' => ['driver_id', 'company_id',  'username', 'sex', 'adm_division_code','birthday','id_card','id_car_front_img','id_car_back_img','id_car_hand_img','head_img','mailing_address','driver_license','driver_license_type', 'license_first_date','license_start_date', 'license_end_date','license_front_img','license_back_img','sign_company','sign_start_date','sign_end_date', 'status'],
    ];
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'driver_id' => 'required|integer',
            'company_id' => 'required|integer',
            'username' => 'required',
            'sex' => 'required',
            'adm_division_code' => 'required',
            'birthday' => 'required|date',
            'id_card' => 'required',
            'id_car_front_img' => 'required',
            'id_car_back_img' => 'required',
            'id_car_hand_img' => 'required',
            'head_img' => 'required',
            'mailing_address' => 'required',
            'driver_license' => 'required',
            'driver_license_type' => 'required',
            'license_first_date' => 'required|date',
            'license_start_date' => 'required|date',
            'license_end_date' => 'required|date',
            'license_front_img' => 'required',
            'license_back_img' => 'required',
            'sign_company' => 'required',
            'sign_start_date' => 'required|date',
            'sign_end_date' => 'required|date',
            'status' => 'required|integer',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        return [
            'id.required' => '参数错误-0',
            'id.integer' => '参数错误-1',
            'company_id.required' => '请选择所属公司',
            'company_id.integer' => '所属公司格式不正确',
            'username.required' => '姓名错误-2',
            'sex.required' => '请填写性别信息',
            'adm_division_code.required' => '请填写注册行政区划代码',
            'birthday.required' => '出生日期不能为空',
            'id_card.required' => '身份证不能为空',
            'id_car_front_img.required' => '身份证正面照片不能为空',
            'id_car_back_img.required' => '身份证背面照片不能为空',
            'id_car_hand_img.required' => '手持身份证照片不能为空',
            'head_img.required' => '司机头像不能为空',
            'mailing_address.required' => '司机通信地址不能为空',
            'driver_license.required' => '机动车驾驶证号不能为空',
            'driver_license_type.required' => '驾证类型不能为空',
            'license_first_date.required' => '请填写驾证初次领取时间',
            'license_first_date.date' => '驾证初次领取时间格式错误',
            'license_start_date.required' => '请填写驾证有效期-1',
            'license_start_date.date' => '驾证有效期格式错误-2',
            'license_end_date.required' => '请填写驾证有效期-2',
            'license_end_date.date' => '驾证有效期格式错误-4',
            'license_front_img.required' => '请上传驾驶照正面',
            'license_back_img.required' => '请上传驾驶照背面',
            'sign_company.required' => '请填写签约协议公司名称',
            'sign_start_date.required' => '请填写签约时间-1',
            'sign_start_date.date' => '签约时间格式错误-1',
            'sign_end_date.required' => '请填写签约时间-2',
            'sign_end_date.date' => '签约时间格式错误-2',
            'status.required' => '状态格式错误-1',
            'status.integer' => '状态格式错误-2',
        ];
    }
}
